//
// Created by lingzhitech on 25-9-18.
//

#ifndef TEXTQUERY_H
#define TEXTQUERY_H

#include <map>
#include <memory>
#include <set>
#include <vector>
#include "QueryResult.h"
// 12章
class TextQuery {
public:
    using line_no = std::vector<std::string>::size_type;

    TextQuery(std::ifstream &);

    QueryResult query(const std::string &) const;

private:
    std::shared_ptr<std::vector<std::string> > file; // input file
    // map of each word to the set of the lines in which that word appears
    std::map<std::string,
        std::shared_ptr<std::set<line_no> > > wm;
};


#endif //TEXTQUERY_H
